﻿using Coldairarrow.Business.Base_leasesystem_signfile;
using Coldairarrow.Entity.Base_leasesystem_signfile;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_leasesystem_signfile
{
    /// <summary>
    /// 合同附件控制器
    /// </summary>
    [Route("/Base_leasesystem_signfile/[controller]/[action]")]
    [OpenApiTag("合同附件控制器")]
    public class leasesystem_signfileController : BaseApiController
    {
        #region DI

        public leasesystem_signfileController(Ileasesystem_signfileBusiness leasesystem_signfileBus)
        {
            _leasesystem_signfileBus = leasesystem_signfileBus;
        }

        Ileasesystem_signfileBusiness _leasesystem_signfileBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<leasesystem_signfile>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _leasesystem_signfileBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<leasesystem_signfile> GetTheData(IdInputDTO input)
        {
            return await _leasesystem_signfileBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(leasesystem_signfile data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _leasesystem_signfileBus.AddDataAsync(data);
            }
            else
            {
                await _leasesystem_signfileBus.UpdateDataAsync(data);
            }
        }

        /// <summary>
        /// 出租人签约协议上传  新增附件数据并更改签约状态
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task SaveDataEmpSign(leasesystem_signfile data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _leasesystem_signfileBus.AddDataEmpSignAsync(data);
            }
        }

        [HttpPost]
        [ApiPermission("signfile.Delete")]
        public async Task DeleteData(List<string> ids)
        {
            await _leasesystem_signfileBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}